
package com.tsh.core.context.config;

import com.tsh.core.context.TshHttpHeadersGetter;
import com.tsh.core.context.listener.TshServletRequestListener;
import com.tsh.core.context.props.TshContextProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * Servlet 监听器自动配置
 *
 * @author Tsh
 */
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class TshServletListenerConfiguration {

	@Bean
	public ServletListenerRegistrationBean<?> registerCustomListener(TshContextProperties properties,
																	 TshHttpHeadersGetter httpHeadersGetter) {
		return new ServletListenerRegistrationBean<>(new TshServletRequestListener(properties, httpHeadersGetter));
	}

}
